<?php
include "configuration.php";
/* Using the functions in this page, you can easily add certain parts of QB into themes,
   or even into your pre-existing site. */

function inputform(){
	// Input form for fish (quotes)
	echo '
<form action="sendmod.php" method="post">
Submit your <img src="fish.png" alt="fish">  below:<br>
<textarea rows="15" cols="50" name="quote">Quote Here...</textarea>
<br>
<table border="0">
<tr><td>Channel: </td><td> <input type="text" size="10" name="channel"> </td> <td> Comments: </td><td> <input type="text" size="10" name="comments"></td></tr>

</table>

<br><br>
<input type="submit" value="SUBMIT THE QUOTE">
</form>
	';
}

function showlinks(){
	// LinkBar at the top of the pages..
	// Just produces the text... Style as you wish
	$linkarray = array(
		"Home" 			=> "./index.php",
		"Go Fishing"	=> "./latest10.php",
		"Random Fish"	=> "./random.php",
		"Add a Fish"	=> "./addquote.php",
		"About"			=> "./aboutqbqd.php",
		);
	foreach($linkarray as $linkname => $linkurl){
		echo "<a href=\"$linkurl\">$linkname</a> / ";
	}
}


function showquote(){
	// Will connect to sql and try to grab $qnumber
	// something like:
	/*
	$sqlret = mysql_connect($sqlserver,$sqluser,$sqlpassword);
	mysql_select_db($sqldb) or die(mysql_error());
		// retrieve the quote and echo it
		*/
	
	// For testing purposes, we'll use a file till we got on the server.
	$quoteget = file_get_contents("qexample.txt");
	echo '<div id="body"> <div id="fishy"><img src="fish.png"><br><br>1</div>'.nl2br(htmlspecialchars($quoteget))."</div><br>";
	echo '<div id="body"> <div id="fishy"><img src="fish.png"><br><br>2</div>'.nl2br(htmlspecialchars($quoteget))."</div><br>";

}

function sendquote($quote,$comm){
global $sqlserver,$sqluser,$sqlpassword,$sqldb;
$sendmod = mysql_connect($sqlserver,$sqluser,$sqlpassword) or die("Could Not open connection to the Database");
mysql_select_db($sqldb);
$safequote    = mysql_real_escape_string($quote);
$safecomments = mysql_real_escape_string($comm);

mysql_query("INSERT INTO queue (ID, quote, comments) VALUES(NULL, '$safequote', '$safecomments' ) ") or die(mysql_error());
mysql_close($sendmod);
}
